from math import exp

def sol_bal(n):
    x=2
    while ... :
        x=...
    return x